package com.neusoft.crm.mapper;

import com.neusoft.crm.po.SysUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 系统角色数据层
 *
 * @author msprc
 */
@Mapper
public interface SysUserMapper {
    /**
     * 根据用户名和密码查找用户
     *
     * @param sysUser 仅包含用户名和密码的系统用户
     * @return 完整用户
     */
    @Select("select * from sysuser where username=#{userName} and userpassword=#{userPassword}")
    SysUser selectSysUserByNameByPass(SysUser sysUser);

    /**
     * 添加系统用户
     *
     * @param sysUser 系统用户
     * @return 受影响的行数
     */
    @Insert("insert into sysUser values(null,#{userName},#{userPassword},#{userRoleId},#{daId},1)")
    int addSystemUserInfo(SysUser sysUser);

    /**
     * 显示系统用户列表
     *
     * @param sysUser 当前系统用户
     * @return 系统用户列表
     */
    List<SysUser> selectSystemUserList(SysUser sysUser);

    /**
     * 更新系统用户
     *
     * @param sysUser 要更新的用户
     * @return 受影响的行数
     */
    @Update("update SysUser set userName=#{userName},userPassword=#{userPassword},userRoleId=#{userRoleId},daId=#{daId},delMark=#{delMark} where userId=#{userId}")
    int updateSystemUserInfo(SysUser sysUser);

    /**
     * 删除系统用户
     *
     * @param sysUser 要删除的用户
     * @return 受影响的行数
     */
    @Update("update SysUser set delMark=0 where userId=#{userId}")
    int deleteSystemUser(SysUser sysUser);
}
